#!/usr/bin/env python
# coding: utf-8

import sys

def main():
    genes = dict()
    for line in sys.stdin:
        genome_id, genes_vectors = line.strip('\n').split('\t')
        for vec in genes_vectors.split(','):
            gene_id, length = vec.split(':')
            genes[int(gene_id)] = length

    for gene_id in sorted(genes):
        length = genes[gene_id]
        print '%s\t%s' % (gene_id, length)

main()

